#pragma once
#include <iostream>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <sstream>
#include <opencv.hpp>
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>

#include "Half_thinning_Algorithm.h"
#include "Tools.h"
#include "LinkedList.h"

using namespace std;
using namespace Tools;
class StrokeBuilder
{
public:
	// Constructor
	StrokeBuilder(void);
	// Destructor
	~StrokeBuilder(void);
	// Refine stroke graph
	void refine_stroke_graph(vector<StrokeNode*> stroke_graph);
	// Build SPWT (Sample Points of Writing Trajectoires) for each substroke
	void build_spwt(char* source_img_name, vector<StrokeNode*> stroke_graph);
	vector<vector<StrokeNode*>> search_path(vector<StrokeNode*> stroke_graph);
private:
	// Build SPWT for a substroke
	void build_stroke_spwt(IplImage* source_image, StrokeNode* stroke);

	// Decide if a connection between 2 substroke is joined or not
	bool decide(int x0, float x1, float x2, float x3, float x4);

};

